▪️ A limitation with the t-test is that only
two means can be compared at one time.
▪️ However, in many experimental set-ups we want to compare more than
two means simultaneously.
▪️ Testing each pair of means with a t-test is not recommended as the probability of false positives increases with each test run.
Analysis of Variance (ANOVA) is the recommended method for determining whether or not there is a statistically significant difference between the means of three or more independent groups.
These levels may represent:
a) quantitative variations (e.g. the effect of
different concentrations of an antibiotic on bacterial growth).
b) qualitative variations (e.g. the effect of apple cultivar on sugar/acid ratio).
A) The Total Variation: the
variation among all the units in the study.
B) Between-Group Variation: the
variation due to the effect of experimental treatments or control groups
(explained variation).
C) Within-Group Variation: the variation due to other sources (error variation).
Consider an experiment where we compare the
bioaccesibility of Vitamin D depending on the type of flour used in a
baked product.
▪️ The fibres used are :wheat pea, apple,
Fibre into R| Fibre | Replicate | Bioaccessibility |
|---|---|---|
| Wheat | 1 | 80 |
| Wheat | 2 | 83 |
| Wheat | 3 | 74 |
| Wheat | 4 | 86 |
| Wheat | 5 | 82 |
| Wheat | 6 | 88 |
| Pea | 1 | 77 |
| Pea | 2 | 71 |
| Pea | 3 | 81 |
| Pea | 4 | 78 |
- The distance of each sample from the blue line represents the deviation of each measurement from the total mean. The sum of all the deviations is zero.
## [1] 624.5
| Fibre | GM |
|---|---|
| Apple | 85.00000 |
| Pea | 75.33333 |
| Wheat | 82.16667 |
- The distance of each sample from the red line is the difference of each measurement from the group mean. This is the ‘left over’ variation attributed to differences among individuals.
## [1] 328.1667
- The distance of each dot from the blue line is the difference between each group mean and the Total Mean. This is variation due to differences among treatment groups.
## [1] 296.3333
📝 The SUM of SQUARES we calculated earlier are related by the
formula:
\({SST = SSG + SSE}\)
Thus the total variation is composed of two parts, one due to groups and one due to error.
DFT = (Number of observations - 1)
DFG = (Number of treatment groups - 1)
DFE = (Number of observations - Number of groups)
The Sum of Squares for each type of variation in ANOVA is calculated as:
\({MST = \frac{SST}{DFT}}\)
\({MSG = \frac{SSG}{DFG}}\)
The Mean Sum of Squares is the standardised form of the Sum of Squares.
To test the Null Hypothesis in a One-Way ANOVA we calculate the F statistic:
\[{F = \frac{MSG}{MSE}}\]## [1] 17
## [1] 2
## [1] 15
## [1] "mst= 36.74"
## [1] "msg= 148.17"
## [1] "mse= 21.88"
## [1] "f=msg/mse= 6.77"
The F statistic is 6.77.
- If we look at an F table for critical values for
α=0.05, the critical value for F(2,15) is 3.68 which is smaller
than our F value. So we can reject the Null hypothesis.
▪️ Another statistic we can calculate from an ANOVA
table is the coefficient of determination
\({R^2 = \frac{SSG}{SST}}\).
## [1] 0.4745129
▪️ This coefficient tells us that 47.5% of the total variation in Bioaccessibility is explained by the different type of fibre and the other 52.5% is explained by sample-to-sample variation within each group.
lm() and aov() functions. ## Df Sum Sq Mean Sq F value Pr(>F)
## as.factor(fibre$Fibre) 2 296.3 148.17 6.772 0.00802 **
## Residuals 15 328.2 21.88
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Check if the values in the ANOVA summary table match the values we got by doing the calculations manually.
▪️ The continuous
variable has a NORMAL distribution in ALL relevant populations (groups)
or at least it doesn’t have any gross outliers.
▪️ Not as important if the sample is large (Central
Limit Theorem).
▪️ If the sample is far from normal &/or small, we may need to consider alternative methods (non-parametric).
QQ plots sort data in ascending order, and plot them against quantiles from a theoretical normal distribution.
The main assumption the residuals need to meet are
the following:
Let’s check the assumptions for the fibre
dataset.
No severe deviations from normality
Again, we don’t see any deviations from this assumption. To make sure we can apply Levene test.
In the Bioaccessibility example we rejected the null
hypothesis (All Means are Equal) in favour of the Alternative hypothesis
(Not All Means are Equal).
▪️ This however is not very informative. We want to
know which group means are statistically significantly different.
▪️ To do this we need to make multiple pairwise
comparisons using t-tests.
▪️ However, when many t-tests are applied simultaneously we run the risk of false positives.
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Bioaccessibility ~ as.factor(fibre$Fibre), data = fibre)
##
## $`as.factor(fibre$Fibre)`
## diff lwr upr p adj
## Pea-Apple -9.666667 -16.6810832 -2.652250 0.0072578
## Wheat-Apple -2.833333 -9.8477499 4.181083 0.5586372
## Wheat-Pea 6.833333 -0.1810832 13.847750 0.0567231
Which pairs of techniques vary significantly?